package com.aboo.dao.frame;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.aboo.constant.CommonConstant;
import com.aboo.dao.BaseDao;
import com.aboo.parameter.frame.ResultParameter;
import com.aboo.po.BasePO;
import com.aboo.po.frame.ResultPO;
import com.aboo.util.ArrayListUtils;

public class ResultDao extends BaseDao implements IResultDao {

	public List<ResultPO> findByCondition(ResultParameter param) {
		List<ResultPO> result = null;
		
		if (param != null) {
			StringBuffer hql = new StringBuffer(" from ResultPO where inuse='" + CommonConstant.INUSE_YES + "'");
			Map<String, Object> params = new HashMap<String, Object>();
			if (param.getResultCode() != null) {
				hql.append(" and resultCode=:resultCode");
				params.put("resultCode", param.getResultCode());
			}
			if (param.getResultInfo() != null) {
				hql.append(" and resultInfo=:resultInfo");
				params.put("resultInfo", param.getResultInfo());
			}
			
			result = new ArrayListUtils<ResultPO, BasePO>().convert(this.findByCondition(hql.toString(), params));
		}
		
		return result;
	}

}
